class DateUtil{

  formatDate(num: number): string{
    let date = new Date(num)
    let year = date.getFullYear()
    let month = date.getMonth()+1
    let day = date.getDate()
    let m = month
    let d = day
    return `${year}/${m}/${d}`
  }

  beginTimeOfDay(date: Date){
    let d = new Date(date.getFullYear(), date.getMonth(), date.getDate())
    return d.getTime()
  }

  subDay(startDate:string,endDate:string):number{
    var date1 = new Date(startDate)
    var date2 = new Date(endDate)
    return (date2.getTime() - date1.getTime())/(1000*24*3600)
  }
}

let dateUtil = new DateUtil()

export default dateUtil as DateUtil